/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2204 - Arr8
 * <p>Powered by webrx On 2022-09-06 14:57:12
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr8 {
    public static void main(String[] args) {
        Student[] ss = new Student[]{
                new Student(1, "李四", 92),
                new Student(2, "张三丰", 10),
                new Student(3, "李强", 80),
                new Student(8, "王五", 80),
                new Student(66, "张三", 88),
                new Student(27, "赵丽", 90),
                new Student(12, "李丽丽", 20),
                new Student(18, "周五", 59),
        };

        System.out.println(Arrays.toString(ss));

        Arrays.sort(ss, (a, b) -> Math.random() > .5 ? 1 : -1);
        System.out.println(Arrays.toString(ss));

        //根据成绩排序
        Arrays.sort(ss,(a,b)->b.getScore()-a.getScore());
        System.out.println(Arrays.toString(ss));


        //根据学生对象的姓名排序（升序 降序不影响人，但是必须有顺序）
        Arrays.sort(ss, (a, b) -> a.getName().compareTo(b.getName()));
        System.out.println(Arrays.toString(ss));

    }
}
